<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box1{
      width: 100px;
      height: 100px;
      background: red;
    }
    /* 根据vue提供的6个状态，定义不同状态的样式即可 */
    /* .v-enter{
      opacity: 0;
    }
    .v-enter-active{
      transition: all 2s;
    }
    .v-enter-to{
      opacity: 1;
    }
    .v-leave{
      opacity: 1;
    }
    .v-leave-active{
      transition: all 2s;
    }
    .v-leave-to{
      opacity: 0;
    } */
    .v-enter,.v-leave-to{
      opacity: 0;
      transform: translateX(100px);
    }
    .v-enter-active,.v-leave-active{
      transition: all 2s;
    }

    .box2{
      width: 100px;
      height: 100px;
      background: green;
    }
     /* 类的前缀，和transition标签的name属性有关 */
    .box2-enter,.box2-leave-to{
      height: 0;
    }
    .box2-enter-active,.box2-leave-active{
      transition: all 2s;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="isShow=!isShow">切换元素的淡入和淡出</button>
    <!-- 实现进入和离开动画需要加上一个transition组件，包裹需要实现动画的元素|组件 -->
    <transition>
      <div v-show="isShow" class="box1"></div>
    </transition>
    <hr>
    <button @click="isOpen=!isOpen">切换元素的展开与收起</button>
    <transition name="box2">
      <div v-if="isOpen" class="box2"></div>
    </transition>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data () {
        return {
          isShow: true,
          isOpen: true
        }
      }
    })
  </script>
</body>
</html>